import Vue from 'vue'
import App from './App.vue'
import './registerServiceWorker'
import router from './router'
import store from './store'
Vue.config.productionTip = false
import 'reset-css'
import './assets/css/common.css'//定义公共的css样式
import '../vant.Config'//配置vant引入
import "./assets/icon/iconfont.css"//引入矢量图
import axios from 'axios';
// 代码开发环境
if (process.env.NODE_ENV === 'development') {
  axios.defaults.baseURL = 'http://localhost:3021/';
}
// 生产环境（线上测试……）
if (process.env.NODE_ENV === 'production') {
  axios.defaults.baseURL = 'http://api.ywg.cool/';
}
Vue.prototype.$baseURL = axios.defaults.baseURL;
// 百度pai
import BaiduMap from 'vue-baidu-map'
router.beforeEach((to,from,next)=>{
  var isAuthenticated ;
  try {
    isAuthenticated = JSON.parse(window.localStorage.getItem('user_token'));
  }catch(e){
    console.log(e);
    isAuthenticated = {}
  }
  if (to.name !== 'Login' && !isAuthenticated) next({ name: 'Login' })
  else next()
})
Vue.use(BaiduMap, {
  /* Visit http://lbsyun.baidu.com/apiconsole/key for details about app key. */
  ak: '0rn8l1RiKLcgLs1mX5N0pTMKVpkNjVyU'
})
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
